home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / imap / ANSI / c-client / mmdf.h < prev    next >
C/C++ Source or Header  |  1994-06-17  |  8KB  |  165 lines

  1. /*
  2.  * Program:    MMDF mail routines
  3.  *
  4.  * Author:    Mark Crispin
  5.  *        Networks and Distributed Computing
  6.  *        Computing & Communications
  7.  *        University of Washington
  8.  *        Administration Building, AG-44
  9.  *        Seattle, WA  98195
  10.  *        Internet: MRC@CAC.Washington.EDU
  11.  *
  12.  * Date:    15 May 1993
  13.  * Last Edited:    17 June 1994
  14.  *
  15.  * Copyright 1994 by the University of Washington
  16.  *
  17.  *  Permission to use, copy, modify, and distribute this software and its
  18.  * documentation for any purpose and without fee is hereby granted, provided
  19.  * that the above copyright notice appears in all copies and that both the
  20.  * above copyright notice and this permission notice appear in supporting
  21.  * documentation, and that the name of the University of Washington not be
  22.  * used in advertising or publicity pertaining to distribution of the software
  23.  * without specific, written prior permission.  This software is made
  24.  * available "as is", and
  25.  * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
  26.  * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
  27.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
  28.  * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
  29.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  30.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
  31.  * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
  32.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33.  *
  34.  */
  35.  
  36.  
  37. #define bezerk_local mmdf_local    /* must be before the include of bezerk.h */
  38. #define BEZERKLOCAL MMDFLOCAL
  39. #include "bezerk.h"        /* most of our stuff comes from this guy */
  40.  
  41. /* Supposedly, this page has everything the MMDF driver needs to know about
  42.  * the MMDF delimiter.  By changing these macros, the MMDF driver should
  43.  * change with it.  Note that if you change the length of MMDFHDRTXT you
  44.  * also need to change the ISMMDF and RETIFMMDFWRD macros to reflect the new
  45.  * size.
  46.  */
  47.  
  48.  
  49. /* Useful MMDF constants */
  50.  
  51. #define MMDFCHR '\01'        /* MMDF character */
  52. #define MMDFCHRS 0x01010101    /* MMDF header character spread in a word */
  53.                 /* MMDF header text */
  54. #define MMDFHDRTXT "\01\01\01\01\n"
  55.                 /* length of MMDF header text */
  56. #define MMDFHDRLEN sizeof (MMDFHDRTXT) - 1
  57.  
  58.  
  59. /* Validate MMDF header
  60.  * Accepts: pointer to candidate string to validate as an MMDF header
  61.  * Returns: T if valid; else NIL
  62.  */
  63.  
  64. #define ISMMDF(s)                            \
  65.   ((*(s) == MMDFCHR) && ((s)[1] == MMDFCHR) && ((s)[2] == MMDFCHR) &&    \
  66.    ((s)[3] == MMDFCHR) && ((s)[4] == '\n'))
  67.  
  68.  
  69. /* Return if a 32-bit word has the start of an MMDF header
  70.  * Accepts: pointer to word of four bytes to validate as an MMDF header
  71.  * Returns: pointer to MMDF header, else proceeds
  72.  */
  73.  
  74. #define RETIFMMDFWRD(s) {                        \
  75.   if (s[3] == MMDFCHR) {                        \
  76.     if ((s[4] == MMDFCHR) && (s[5] == MMDFCHR) && (s[6] == MMDFCHR) &&    \
  77.     (s[7] == '\n')) return s + 3;                    \
  78.     else if (s[2] == MMDFCHR) {                        \
  79.       if ((s[4] == MMDFCHR) && (s[5] == MMDFCHR) && (s[6] == '\n'))    \
  80.     return s + 2;                            \
  81.       else if (s[1] == MMDFCHR) {                    \
  82.     if ((s[4] == MMDFCHR) && (s[5] == '\n')) return s + 1;        \
  83.     else if ((*s == MMDFCHR) && (s[4] == '\n')) return s;        \
  84.       }                                    \
  85.     }                                    \
  86.   }                                    \
  87. }
  88.  
  89. /* Function prototypes */
  90.  
  91. DRIVER *mmdf_valid (char *name);
  92. int mmdf_isvalid (char *name,char *tmp);
  93. void *mmdf_parameters (long function,void *value);
  94. void mmdf_find (MAILSTREAM *stream,char *pat);
  95. void mmdf_find_bboards (MAILSTREAM *stream,char *pat);
  96. void mmdf_find_all (MAILSTREAM *stream,char *pat);
  97. void mmdf_find_all_bboards (MAILSTREAM *stream,char *pat);
  98. long mmdf_subscribe (MAILSTREAM *stream,char *mailbox);
  99. long mmdf_unsubscribe (MAILSTREAM *stream,char *mailbox);
  100. long mmdf_subscribe_bboard (MAILSTREAM *stream,char *mailbox);
  101. long mmdf_unsubscribe_bboard (MAILSTREAM *stream,char *mailbox);
  102. long mmdf_create (MAILSTREAM *stream,char *mailbox);
  103. long mmdf_delete (MAILSTREAM *stream,char *mailbox);
  104. long mmdf_rename (MAILSTREAM *stream,char *old,char *new);
  105. MAILSTREAM *mmdf_open (MAILSTREAM *stream);
  106. void mmdf_close (MAILSTREAM *stream);
  107. void mmdf_fetchfast (MAILSTREAM *stream,char *sequence);
  108. void mmdf_fetchflags (MAILSTREAM *stream,char *sequence);
  109. ENVELOPE *mmdf_fetchstructure (MAILSTREAM *stream,long msgno,BODY **body);
  110. char *mmdf_fetchheader (MAILSTREAM *stream,long msgno);
  111. char *mmdf_fetchtext (MAILSTREAM *stream,long msgno);
  112. char *mmdf_fetchbody(MAILSTREAM *stream,long m,char *sec,unsigned long *len);
  113. void mmdf_setflag (MAILSTREAM *stream,char *sequence,char *flag);
  114. void mmdf_clearflag (MAILSTREAM *stream,char *sequence,char *flag);
  115. void mmdf_search (MAILSTREAM *stream,char *criteria);
  116. long mmdf_ping (MAILSTREAM *stream);
  117. void mmdf_check (MAILSTREAM *stream);
  118. void mmdf_expunge (MAILSTREAM *stream);
  119. long mmdf_copy (MAILSTREAM *stream,char *sequence,char *mailbox);
  120. long mmdf_move (MAILSTREAM *stream,char *sequence,char *mailbox);
  121. long mmdf_append (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
  122.           STRING *message);
  123. void mmdf_gc (MAILSTREAM *stream,long gcflags);
  124.  
  125. void mmdf_abort (MAILSTREAM *stream);
  126. char *mmdf_file (char *dst,char *name);
  127. int mmdf_lock (char *file,int flags,int mode,char *lock,int op);
  128. void mmdf_unlock (int fd,MAILSTREAM *stream,char *lock);
  129. int mmdf_parse (MAILSTREAM *stream,char *lock,int op);
  130. char *mmdf_eom (char *som,char *sod,long i);
  131. int mmdf_extend (MAILSTREAM *stream,int fd,char *error);
  132. void mmdf_save (MAILSTREAM *stream,int fd);
  133. int mmdf_copy_messages (MAILSTREAM *stream,char *mailbox);
  134. int mmdf_write_message (int fd,FILECACHE *m);
  135. void mmdf_update_status (char *status,MESSAGECACHE *elt);
  136. short mmdf_getflags (MAILSTREAM *stream,char *flag);
  137. char mmdf_search_all (MAILSTREAM *stream,long msgno,char *d,long n);
  138. char mmdf_search_answered (MAILSTREAM *stream,long msgno,char *d,long n);
  139. char mmdf_search_deleted (MAILSTREAM *stream,long msgno,char *d,long n);
  140. char mmdf_search_flagged (MAILSTREAM *stream,long msgno,char *d,long n);
  141. char mmdf_search_keyword (MAILSTREAM *stream,long msgno,char *d,long n);
  142. char mmdf_search_new (MAILSTREAM *stream,long msgno,char *d,long n);
  143. char mmdf_search_old (MAILSTREAM *stream,long msgno,char *d,long n);
  144. char mmdf_search_recent (MAILSTREAM *stream,long msgno,char *d,long n);
  145. char mmdf_search_seen (MAILSTREAM *stream,long msgno,char *d,long n);
  146. char mmdf_search_unanswered (MAILSTREAM *stream,long msgno,char *d,long n);
  147. char mmdf_search_undeleted (MAILSTREAM *stream,long msgno,char *d,long n);
  148. char mmdf_search_unflagged (MAILSTREAM *stream,long msgno,char *d,long n);
  149. char mmdf_search_unkeyword (MAILSTREAM *stream,long msgno,char *d,long n);
  150. char mmdf_search_unseen (MAILSTREAM *stream,long msgno,char *d,long n);
  151. char mmdf_search_before (MAILSTREAM *stream,long msgno,char *d,long n);
  152. char mmdf_search_on (MAILSTREAM *stream,long msgno,char *d,long n);
  153. char mmdf_search_since (MAILSTREAM *stream,long msgno,char *d,long n);
  154. char mmdf_search_body (MAILSTREAM *stream,long msgno,char *d,long n);
  155. char mmdf_search_subject (MAILSTREAM *stream,long msgno,char *d,long n);
  156. char mmdf_search_text (MAILSTREAM *stream,long msgno,char *d,long n);
  157. char mmdf_search_bcc (MAILSTREAM *stream,long msgno,char *d,long n);
  158. char mmdf_search_cc (MAILSTREAM *stream,long msgno,char *d,long n);
  159. char mmdf_search_from (MAILSTREAM *stream,long msgno,char *d,long n);
  160. char mmdf_search_to (MAILSTREAM *stream,long msgno,char *d,long n);
  161.  
  162. search_t mmdf_search_date (search_t f,long *n);
  163. search_t mmdf_search_flag (search_t f,char **d);
  164. search_t mmdf_search_string (search_t f,char **d,long *n);
  165.